﻿

var TT = TT || {};

TT.Settings = {};
TT.Settings.TypekitId = 'ahi8ewx';
TT.Settings.LoadAnimations = new Array();


TT.Common = {};

//- Initialise global UI 
TT.Common.Init = function () {
    TT.Common.LoadFonts();
    $("body").addClass("ready");
    TT.Common.Preload();
}

//- Load in fonts from Typekit 
TT.Common.LoadFonts = function () {
    var config = {
        kitId: TT.Settings.TypekitId,
        scriptTimeout: 3000
    };
    var h = document.getElementsByTagName("html")[0]; h.className += " wf-loading"; var t = setTimeout(function () { h.className = h.className.replace(/(\s|^)wf-loading(\s|$)/g, " "); h.className += " wf-inactive" }, config.scriptTimeout); var tk = document.createElement("script"), d = false; tk.src = '//use.typekit.net/' + config.kitId + '.js'; tk.type = "text/javascript"; tk.async = "true"; tk.onload = tk.onreadystatechange = function () { var a = this.readyState; if (d || a && a != "complete" && a != "loaded") return; d = true; clearTimeout(t); try { Typekit.load(config) } catch (b) { } }; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(tk, s)
}

TT.Common.AddLoadingAnimation = function( el, colour ){
    var $loader = TT.Settings.LoadAnimations[colour].show();
    $(el).height($(el).height()).width($(el).width());
    $(el).html($loader);
}


TT.Common.Preload = function(){
	var colour = "red";
	var $loadingRed = $('<img />').attr("src", "/img/loading-" + colour + ".gif")
                              .attr("alt", "Loading...")
                              .addClass("loading")
                              .hide();
  TT.Settings.LoadAnimations["red"] = $loadingRed;  
}



$(function () {

    TT.Common.Init();

});